<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="admin/commons :: head(~{::title})">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title th:text="*{id} == null ? '标签新增' : '标签修改'">标签新增</title>
<!--    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">-->
<!--    <link rel="stylesheet" th:href="@{/css/semantic.min.css}">-->
<!--    <link rel="stylesheet" th:href="@{/css/style.css}">-->
</head>
<body>

    <!--头部导航开始-->
    <!--thymeleaf 片段替换-->
    <div th:replace="admin/commons :: header(3)"></div>
    <!--头部导航结束-->

    <!--二级导航-->
    <div class="ui attached pointing menu">
        <div class="ui container">
            <div class="right menu">
                <a th:href="@{/admin/tags/input}" class="active teal item">新增</a>
                <a th:href="@{/admin/tags}" class="item">列表</a>
            </div>
        </div>
    </div>

    <!--中间部分开始-->
    <div class="v-container-small v-padded-tb-big">
        <div class="ui container">
            <!--根据id判断是更新还是添加-->
            <form class="ui form" th:object="${tag}" th:action="*{id} == null ? @{/admin/tags} : @{/admin/tags/{id}(id=*{id})}" method="post">
                <!--传递id-->
                <input type="hidden" name="id" th:value="*{id}">

                <div class="required field">
                    <div class="ui left labeled input">
                        <label class="ui teal basic label">名称</label>
                        <!--防止该页面被模板引擎渲染时报错-->
                        <input type="text" name="name" placeholder="标签名称" th:value="*{name}">
                    </div>
                </div>

                <div class="ui error message"></div>

                <!--后台Validator校验，一下会被模板引擎识别-->
                <!--/*/<div class="ui negative message" th:if="${#fields.hasErrors('name')}">
                    <i class="close icon"></i>
                    <div class="header">验证失败</div>
                    <p th:errors="*{name}">提交信息不符合规则</p>
                </div>/*/-->

                <div class="ui right aligned container">
                    <button type="button" class="ui button" onclick="history.go(-1)">返回</button>
                    <button class="ui teal submit button" th:text="*{id} == null ? '新增' : '修改'">提交</button>
                </div>
            </form>

        </div>
    </div>
    <!--中间部分结束-->
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>

    <!--底部部分开始-->
    <!--thymeleaf 片段替换-->
    <div th:replace="admin/commons :: #footer"></div>
    <!--底部部分结束-->



    <!--<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>-->
<!--<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>-->
<!--<script th:src="@{/js/jquery-3.6.0.min.js}"></script>-->
<!--<script th:src="@{/js/semantic.min.js}"></script>-->
<!--/*/<th:block th:replace="admin/commons :: script">/*/-->
    <!--thymeleaf 引入js资源，这三行不为注释-->
<!--/*/</th:block>/*/-->
<script>
    $('.ui.form').form({
        fields: {
            name: {
                identifier: 'name',
                rules: [{
                    type: 'empty',
                    prompt:'请输入标签名称'
                }]
            }
        }
    });

    $('.menu.toggle').click(function () {
        $('.v-item').toggleClass('v-mobile-hidden')
    });

    $('.ui.dropdown').dropdown({
        on: 'hover'
    });

    //消息提示关闭
    $('.message .close').on('click', function() {
        $(this).closest('.message').transition('fade');
    });
</script>
</body>
</html>

